

#include <config.h>

#ifndef __GDT_H
#  define __GDT_H

#  ifdef CONF_SYS_AMD64

struct __GDT {

  unsigned long int base;
  unsigned short limit;

} __attribute__ ((packed));

typedef struct __gdt GDT;

struct __GDT_entry {

  unsigned int  low_ignored;
  unsigned char mid_low_ignored;
  unsigned      ign1 : 2;
  unsigned      conf : 1;
  unsigned      data_code : 2;
  unsigned      dpl : 2;
  unsigned      present : 1;
  unsigned char low_flags;
  unsigned char high_flags;
  unsigned char high_ignored;

} __attribute__ ((packed));

typedef struct __GDT_entry GDT_entry;

#  define GDT_FLAG_D    0x10
#  define GDT_FLAG_LONG 0x20
#  define GDT_CODE_SEG  3     // 11b
#  define GDT_DATA_SEG  2     // 10b

#  define CODE_SEG(entry) entry.data_code = GDT_CODE_SEG;
#  define DATA_SEG(entry) entry.data_code = GDT_DATA_SEG;

#  endif

#endif
